package net.lateeye.search;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Properties;

/**
 * Not necesarily "abstract". this class can be used without extension. but it
 * is recommended to extend this.
 * 
 * @author Isao Isaac Saito <130s@lateeye.net>
 * 
 */
public class SearchResult implements Result
{
	LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();

	private Properties prop = new Properties();

	public static final String DESC = "desc";
	public static final String URI = "url";
	public static final String DOCID = "docid";
	public static final String TITLE = "title";
	/**
	 * Title that is just extracted according to the specified algorithm without
	 * any modification
	 * 
	 * @author 130s@lateeye.net
	 * @since 1/4/11
	 */
	public static final String TITLE_RAW = "title_raw";
	public static final String ORDER = "order";

	public void setDescription(String desc)
	{
		this.map.put(DESC, desc);
	}

	public void setDocumentURI(String uri)
	{
		this.map.put(URI, uri);
	}

	public void setDocumentID(String uri)
	{
		this.map.put(DOCID, uri);
	}

	public void setFields(NameValuePair[] fieldNameAndValues)
	{
		for (int i = 0; i < fieldNameAndValues.length; i++) {
			this.map.put(fieldNameAndValues[i].getName(), fieldNameAndValues[i]
					.getValue());
		}
	}

	// public String getLanguage() {
	// // TODO Auto-generated method stub
	// return null;
	// }
	// public Properties getProperties() {
	// // TODO Auto-generated method stub
	// return null;
	// }
	// public String getProperty(String arg0) {
	// // TODO Auto-generated method stub
	// return null;
	// }
	// public double getScore() {
	// // TODO Auto-generated method stub
	// return 0;
	// }

	public void setTitle(String title)
	{
		this.map.put(TITLE, title);
	}

	/**
	 * Set the title that is just extracted according to the specified algorithm
	 * without any modification
	 * 
	 * @author Isao Isaac Saito <130s@lateeye.net>
	 * @since 1/4/11
	 */
	public void setTitle_Raw(String title_raw)
	{
		this.map.put(TITLE_RAW, title_raw);
	}

	/**
	 * existence of the idea "collection" depends on platform
	 */
	public String getCollectionID()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public Date getDate()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public String getDescription()
	{
		return (String) this.map.get(SearchResult.DESC);
	}

	public String getDocumentID()
	{
		return (String) this.map.get(SearchResult.DOCID);
	}

	public String getDocumentSource()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public String getDocumentType()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public String getDocumentURI()
	{
		return (String) this.map.get(SearchResult.URI);
	}

	public NameValuePair[] getFields()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public String[] getFields(String a)
	{
		// String[] strs = (String[]) this.map.get(a);
		String[] strs = new String[1];
		strs[0] = (String) this.map.get(a);
		return strs;
	}

	public Locale getLanguage()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public Properties getProperties()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public String getProperty(String arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	public double getScore()
	{
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * Returns the title that is just extracted according to the specified
	 * algorithm without any modification
	 * 
	 * @author Isao Isaac Saito <130s@lateeye.net>
	 * @since 1/4/11
	 */
	public String getTitle_Raw()
	{
		return (String) this.map.get(TITLE_RAW);
	}

	/**
	 * 
	 * @author Isao Isaac Saito <130s@lateeye.net>
	 * @return Title string that has no modifying tags.
	 */
	public String getTitle()
	{
		return (String) this.map.get(TITLE);
	}

	public boolean isFirstOfASite()
	{
		// TODO Auto-generated method stub
		return false;
	}

	public String getOrder()
	{
		return this.prop.getProperty(ORDER);
	}

	public void setOrder(String o)
	{
		this.prop.setProperty(ORDER, o);
	}

	public String getBody()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public Date getCreatedDate()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public Date getLastDateVisitedByCrawler()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public Date getModifiedDate()
	{
		// TODO Auto-generated method stub
		return null;
	}
}